import axios from "axios";

//1. 创建axios对象
const service = axios.create({
  headers: {
    // 永久请求token
    Authorization:
      "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImMzMDlmYmVlLTljNDctNDRmMS1iNGEzLTg0ZGUzMGY5NzI3YiJ9.nKLKmOiuOu50fi8Dy4LsiHc0jDjdOedOAy2_8fPZ2_wiJDOB99UIo1tSSmwnFUGieeh4NeTbFz7W7TcFkIbAMQ",
  },
  // baseURL: "http://81.68.194.42:9080/",
  baseURL: "http://212.64.11.65:9080",
});

//2. 请求拦截器
service.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    Promise.reject(error);
  }
);

//3. 响应拦截器
service.interceptors.response.use(
  (response) => {
    //判断code码
    return response.data;
  },
  (error) => {
    return Promise.reject(error);
  }
);

export default service;
